package lxs.tool.liberator.work.service.imp;

import lxs.tool.liberator.common.base.result.Response;

import lxs.tool.liberator.common.utils.IDCreator;
import lxs.tool.liberator.work.mapper.FieldMapper;
import lxs.tool.liberator.work.pojo.Field;
import lxs.tool.liberator.work.service.FieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("FieldServiceImp")
public class FieldServiceImp implements FieldService {
    @Autowired
    private FieldMapper fieldMapper;

    @Override
    public Response getByEId(String id) {
        return Response.send(fieldMapper.getByEId(id));
    }

    @Override
    public Response deleteById(String id) {
        fieldMapper.deleteById(id);
        return Response.success();
    }
    @Override
    public Response add(String eid,String key) {
        String s = IDCreator.get("filed");
        fieldMapper.insert(new Field().setId(s).setEntityId(eid).setKey(key));
        return Response.send(s);
    }
    @Override
    public Response update(Field field) {
        fieldMapper.updateById(field);
        return Response.success();
    }
}
